
package dao.lotesdao;

import beans.LoteBeans;
import conexao.Conexao;
import java.sql.PreparedStatement;
import java.sql.SQLException;



public class Gravalotedao {
      
    public Gravalotedao(){
        
    }

    public boolean grava (LoteBeans lote){
        boolean gravou = false;
        String sql = "INSERT INTO lotes_cafe VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        try {
            PreparedStatement comandoSQL = Conexao.getInstance().prepareStatement(sql);            
            
            comandoSQL.setInt(1, 0);
            comandoSQL.setString(2, lote.getLoteNum());
            comandoSQL.setString(3, lote.getBloco());
            comandoSQL.setString(4, lote.getData());            
            comandoSQL.setObject(5, lote.getSafra()); 
            comandoSQL.setObject(6, lote.getPesoBruto());
            comandoSQL.setObject(7, lote.getCatacao());
            comandoSQL.setObject(8, lote.getQuantidade());                     
            comandoSQL.setString(9, lote.getBebida());
            comandoSQL.setObject(10, lote.getFundo());           
            comandoSQL.setObject(11, lote.getImpureza());
            comandoSQL.setObject(12, lote.getPgraos());
            comandoSQL.setObject(13, lote.getPva());
            comandoSQL.setObject(14, lote.getAproveitamento());
            comandoSQL.setObject(15, lote.getProduto());
            comandoSQL.setObject(16, lote.getRecebimento());            
            comandoSQL.execute();
            Conexao.getInstance().commit();
            gravou = true;
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        return gravou;
    }
}